package com.cloud.shopping.goods.mapper;

import com.cloud.shopping.goods.model.Sku;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

/**
 * <p>
 * 商品表 Mapper 接口
 * </p>
 *
 * @author John.zhang
 * @since 2020-12-28
 */
public interface SkuMapper extends BaseMapper<Sku> {

    /**
     * 库存递减
     *
     * @param id id
     * @param num num
     * @return int
     */
    @Update("update sku set num=num-#{num} where id=#{id} and num>=#{num}")
    int dCount(@Param("id") String id, @Param("num") Integer num);

}
